package io.renren.modules.generator.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.generator.dao.ItemDao;
import io.renren.modules.generator.entity.ItemEntity;
import io.renren.modules.generator.service.ItemService;
import io.renren.modules.generator.vo.ListItemAndStockDTO;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("itemService")
public class ItemServiceImpl extends ServiceImpl<ItemDao, ItemEntity> implements ItemService {


    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<ItemEntity> page = this.selectPage(
                new Query<ItemEntity>(params).getPage(),
                new EntityWrapper<ItemEntity>().like(params.containsKey("name"), "name", (String) params.get("name"))
        );

        return new PageUtils(page);
    }

    @Override
    public List<ListItemAndStockDTO> listItemStock() {
        return
        this.baseMapper.listItemAndStock();
    }
}
